/**
 */
package OBSL.impl;

import OBSL.ModeRuleset;
import OBSL.OBSLPackage;

import OBSL.PresentIndividual;
import RefOntoUML.Classifier;
import RefOntoUML.Mode;

import java.lang.reflect.InvocationTargetException;

import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.WrappedException;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mode Ruleset</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.ModeRulesetImpl#getMode <em>Mode</em>}</li>
 *   <li>{@link OBSL.impl.ModeRulesetImpl#getBearerIndividual <em>Bearer Individual</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModeRulesetImpl extends RulesetImpl implements ModeRuleset {
	/**
	 * The cached value of the '{@link #getMode() <em>Mode</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMode()
	 * @generated
	 * @ordered
	 */
	protected Mode mode;

	/**
	 * The cached value of the '{@link #getBearerIndividual() <em>Bearer Individual</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBearerIndividual()
	 * @generated
	 * @ordered
	 */
	protected EList<PresentIndividual> bearerIndividual;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ModeRulesetImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.MODE_RULESET;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Mode getMode() {
		if (mode != null && mode.eIsProxy()) {
			InternalEObject oldMode = (InternalEObject)mode;
			mode = (Mode)eResolveProxy(oldMode);
			if (mode != oldMode) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.MODE_RULESET__MODE, oldMode, mode));
			}
		}
		return mode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Mode basicGetMode() {
		return mode;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMode(Mode newMode) {
		Mode oldMode = mode;
		mode = newMode;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.MODE_RULESET__MODE, oldMode, mode));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<PresentIndividual> getBearerIndividual() {
		if (bearerIndividual == null) {
			bearerIndividual = new EObjectResolvingEList<PresentIndividual>(PresentIndividual.class, this, OBSLPackage.MODE_RULESET__BEARER_INDIVIDUAL);
		}
		return bearerIndividual;
	}

	/**
	 * The cached invocation delegate for the '{@link #classifiedBy() <em>Classified By</em>}' operation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #classifiedBy()
	 * @generated
	 * @ordered
	 */
	protected static final EOperation.Internal.InvocationDelegate CLASSIFIED_BY__EINVOCATION_DELEGATE = ((EOperation.Internal)OBSLPackage.Literals.MODE_RULESET___CLASSIFIED_BY).getInvocationDelegate();

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Classifier classifiedBy() {
		try {
			return (Classifier)CLASSIFIED_BY__EINVOCATION_DELEGATE.dynamicInvoke(this, null);
		}
		catch (InvocationTargetException ite) {
			throw new WrappedException(ite);
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.MODE_RULESET__MODE:
				if (resolve) return getMode();
				return basicGetMode();
			case OBSLPackage.MODE_RULESET__BEARER_INDIVIDUAL:
				return getBearerIndividual();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.MODE_RULESET__MODE:
				setMode((Mode)newValue);
				return;
			case OBSLPackage.MODE_RULESET__BEARER_INDIVIDUAL:
				getBearerIndividual().clear();
				getBearerIndividual().addAll((Collection<? extends PresentIndividual>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_RULESET__MODE:
				setMode((Mode)null);
				return;
			case OBSLPackage.MODE_RULESET__BEARER_INDIVIDUAL:
				getBearerIndividual().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.MODE_RULESET__MODE:
				return mode != null;
			case OBSLPackage.MODE_RULESET__BEARER_INDIVIDUAL:
				return bearerIndividual != null && !bearerIndividual.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
		switch (operationID) {
			case OBSLPackage.MODE_RULESET___CLASSIFIED_BY:
				return classifiedBy();
		}
		return super.eInvoke(operationID, arguments);
	}

} //ModeRulesetImpl
